import axios from 'axios'


// 创建axios实例
const httpAxios = axios.create({
    baseURL: "http://localhost:3000", // api的base_url
    timeout: 2000 // 请求超时时间
})


//自己二次封装请求函数
export function httpGet(url, callback) {
    return httpAxios({
        url: url,
        method: 'get'
    })
}

export function httpPost(url, data, callback) {
    return httpAxios({
        url: url,
        method: 'post',
        data: data
    }).then(function (response) {
        callback(response.data)
    }).catch(function (error) {
        throw error
    })
}